import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class Menu extends JFrame {

	private static final long serialVersionUID = 5520644475993052526L;
	public static int input = 0;
	public static String Player1 = "Player 1";
	public static String Player2 = "Player 2";
	public static String PlayerCPU_Easy = "Player 1";

	public Menu() {
		super("Basketball Totten");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		JButton button1 = new JButton(
				"New Game (Player 1 - Human, Player 2 - Human)");
		button1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String temp1 = JOptionPane
						.showInputDialog("Enter Player 1's name");

				String temp2 = JOptionPane
						.showInputDialog("Enter Player 2's name");

				if (temp1.length() != 0 && temp2.length() != 0) {
					Player1 = temp1;
					Player2 = temp2;
					Main.main(null);
					dispose();
					showRules();
				} else {
					Main.main(null);
					dispose();
					showRules();
				}
			}
		});

		JButton button2 = new JButton(
				"New Game (Player 1 - Human, Player 2 - CPU_Easy)");
		button2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String temp1 = JOptionPane
						.showInputDialog("Enter Player 1's name");

				if (temp1.length() != 0) {
					PlayerCPU_Easy = temp1;
					MainCPU_Easy.main(null);
					dispose();
					showRules();
				} else {
					MainCPU_Easy.main(null);
					dispose();
					showRules();
				}
			}
		});
		JToolBar bar = new JToolBar(null, JToolBar.VERTICAL);
		JMenu label = new JMenu("Basketball Totten - by David Pasternak");
		label.setForeground(Color.BLUE);
		bar.add(label);
		bar.add(button1);
		bar.add(button2);
		JPanel pane = new JPanel();
		pane.add("North", bar);
		pane.setBackground(Color.ORANGE);
		setContentPane(pane);
	}

	public static void showRules() {
		int more = JOptionPane.YES_OPTION;
		more = JOptionPane
				.showConfirmDialog(
						null,
						"Would you like to display the rules of the game? (they can be viewed at any point in the game by clicking GAME>SHOW RULES...)",
						"Show the Rules?", JOptionPane.YES_NO_OPTION);
		if (more == JOptionPane.YES_OPTION) {
			Rules.main(null);
		}
	}

	public static void main(String[] arguments) {
		Menu frame = new Menu();
		frame.pack();
		frame.setVisible(true);
	}
}